﻿using System.Xml;
using System.Xml.Serialization;

namespace GISUtil.KML
{
  /// <summary>
  /// Contains methods for serializing and deserializing the XML found in the ListStyle section of KML
  /// </summary>
  public class ListStyle
  {
    /// <summary>
    /// The unique ID of this style.
    /// </summary>
    [XmlAttribute("Id")]//todo: is the capitalization correct?
    public string Id { get; set; }

    /// <summary>
    /// The list item type associated with this style.
    /// </summary>
    [XmlElement("ListItemType")]
    public ListItemType? ListItemType { get; set; }

    /// <summary>
    /// The background Color of the list.
    /// </summary>
    [XmlElement("bgColor")]
    public string BackgroundColor { get; set; }

    /// <summary>
    /// The Icon associated with this list. 
    /// </summary>
    [XmlElement("ItemIcon")]
    public ItemIcon Icon { get; set; }

    /// <summary>
    /// Determines if this class has any styling information associated with it. 
    /// </summary>
    /// <returns>True if at least one of the fields that contains style information has a value, otherwise false.</returns>
    public bool HasAValue()
    {
      return ListItemType != null ||
        BackgroundColor != null ||
        (Icon != null && Icon.HasAValue());
    }
  }
}